/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.com.globalsolutionslt.controlador;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import sv.com.globalsolutionslt.entidades.TipoCargo;

/**
 *
 * @author karinaMelara
 */
@Stateless
public class TipoCargoFacade extends AbstractFacade<TipoCargo> {

    @PersistenceContext(unitName = "BoldeDeTrabajoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public TipoCargoFacade() {
        super(TipoCargo.class);
    }

    public List<TipoCargo> TipoCargoActivo(Integer a) {

        List<TipoCargo> tipoCargo = null;
        try {
            String sql = "SELECT t FROM TipoCargo t where t.activo=" + true + " and t.idAreaEmpresa.idAreaEmpresa=" + a;
            Query q = em.createQuery(sql);
            tipoCargo = q.getResultList();
        } catch (NoResultException e) {
            System.out.println("Sin resultados");
        }
        return tipoCargo;
    }
}
